package com.moorecat.app;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import com.moorecat.R;
import com.moorecat.http.HttpUtils;
import com.moorecat.utils.ui.ImageUtils;

/**
 * @author pengfei.xu
 * @version 创建时间：2011-6-22 下午02:59:10 类说明
 */
public class ActivityDetail2 extends Activity {

	private TextView activityTip, title;

	private ImageView activityIcon;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_detail2);
		Intent intent = getIntent();
		activityTip = (TextView) findViewById(R.id.activity_tip);
		title = (TextView) findViewById(R.id.activity_name);
		activityIcon = (ImageView) findViewById(R.id.activity_pic);
		title.setText(intent.getStringExtra("title"));
		activityTip.setText(intent.getStringExtra("content"));
		Bitmap icon = ImageUtils.drawableToBitmap(getResources().getDrawable(
				R.drawable.m_activity_pic));
		activityIcon.setImageBitmap(icon);
		new AvatarTask().execute(intent.getIntExtra("activityId", 0) + "",
				intent.getStringExtra("picPath"));
	}

	private class AvatarTask extends AsyncTask<String, Integer, Bitmap> {

		@Override
		protected Bitmap doInBackground(String... params) {
			Bitmap bitmap = null;
			bitmap = HttpUtils.downloadBitmap(params[1]);
			return bitmap;
		}

		@Override
		protected void onPostExecute(Bitmap result) {
			super.onPostExecute(result);
			if (result != null) {
				activityIcon.setImageBitmap(result);
			}
		}

	}

}
